<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>{:session('cp.cpsysname')}--系统管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">

    <title>一什智慧城后台管理系统</title>
    <script src="__STATIC_URL__/static/js/jquery-1.10.2.min.js"></script>
    <link href="__STATIC_URL__/static/css/style.css" rel="stylesheet">
    <link href="__STATIC_URL__/static/css/style-responsive.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC_URL__/static/css/login.css">

</head>

<body class="login-body">
<form method="post" id="frm">
    <div style="display:table; height:100%;width:100%;">
        <div style="display:table-cell; vertical-align:middle; text-align:center;">
            <div class="login-form">
                <div id="admintype" class="text-center">管理员登陆</div>
                <div class="login-tab login-tab-r" style="width: 100%;">
                    <a href="javascript:void(0)" class="">管理员登陆账户登录</a>
                </div>
                <div class="login-box" style="display: block;">
                    <div class="form-group">
                        <input type="text" name="username" class="form-control" placeholder="账号" autofocus value="{$Think.cookie.username}" id="username">
                    </div>
                    <div class="form-group">
                        <input type="password" name='password' value="{$Think.cookie.password}" class="form-control" placeholder="密码">
                    </div>
                    <div class="form-group" style="position:relative;">
                    <input type='text' class='form-control' name='code' id="code" style='width:150px;' placeholder="清输入验证码">
                    <img src="{:captcha_src()}" alt="captcha" id="verify_img" width='100' class="img-responsive" style='float:right;position: absolute;top: 0;right: 0px;' onclick="refreshVerify()" />
                    </div>
                    <div class="form-group">
                        <input id="submit" type="button" class="btn btn-primary btn-block" onclick="check()" value="登录">
                    </div>
                    <div class="msg">

                    </div>
                </div>
            </div>
        </div>
    </div>
</form>

<!-- Placed js at the end of the document so the pages load faster -->

<!-- Placed js at the end of the document so the pages load faster -->

<script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="__STATIC_URL__/static/js/modernizr.min.js"></script>
<script src="__STATIC_URL__/static/js/qrcode/qrcode.js"></script>
<script src="__STATIC_URL__/static/layer/layer.js"></script>
<script type="text/javascript">

    <!--回车键事件-->
    document.onkeydown = function (e) {
        var theEvent = window.event || e;
        var code = theEvent.keyCode || theEvent.which;
        if (code == 13) {
            check();
        }
    }
//    登录函数
    function check() {
        $.ajax({
            type: "POST",
            url: "{:url('Login/login')}",
            cache: false,
            data: $('#frm').serialize(),
            success: function (data) {
                refreshVerify();
                $("#code").val("");
                if(data.code==0){
                    layer.msg(data.message);
                    setTimeout(tz(data.url), 1000);
                }else if(data.code==4){
                   alert(data.message);
                    return false;
                }
                else{
                    alert(data.message);
                    return false;
                }
            }

        });
    }
//    刷新验证码函数
    function refreshVerify() {
        var ts = Date.parse(new Date()) / 1000;
        $('#verify_img').attr("src", "/captcha?id=" + ts);
    };
//提交数据页面跳转
    function tz(url) {
        window.location.href =url;
    }

</script>

</body>
</html>
